//
//  ESTHorizontalValueView.m
//  ESTSCRMAPP
//
//  Created by 李贤立 on 2018/10/15.
//  Copyright © 2018年 Capfer. All rights reserved.
//

#import "ESTHorizontalValueView.h"
@interface ESTHorizontalValueView ()
@property (weak, nonatomic) IBOutlet UIButton *nameButton;
@property (weak, nonatomic) IBOutlet UIButton *valueButton;
@property (weak, nonatomic) IBOutlet UIButton *coverButton;

@end
@implementation ESTHorizontalValueView

- (instancetype)init {
    return [[NSBundle mainBundle] loadNibNamed:@"ESTHorizontalValueView" owner:nil options:nil].lastObject;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    self.nameButton.titleLabel.textAlignment = NSTextAlignmentLeft;
    self.valueButton.titleLabel.textAlignment = NSTextAlignmentLeft;
}

/**
 创建水平的名称和值的控件

 @param name 名称
 @param value 值
 @param clickValue 点击值的回调
 @return 创建的控件
 */
+ (instancetype)creatHorizontalValueViewWithName:(NSString *)name value:(NSString *)value clickValue:(void(^)(void))clickValue {
    ESTHorizontalValueView *view = [[ESTHorizontalValueView alloc] init];
    view.name = name;
    view.value = value;
    view.didClickValueBlock = clickValue;
    view.coverButton.hidden = YES;
    return view;
}
- (void)setName:(NSString *)name {
    _name = name;
    [self.nameButton setTitle:name forState:UIControlStateNormal];
}
- (void)setValue:(NSString *)value {
    _value = value;
    [self.valueButton setTitle:value forState:UIControlStateNormal];
}
- (IBAction)didClickNameButton:(UIButton *)sender {
    if (self.didClickNameBlock) {
        self.didClickNameBlock();
    }
}
- (IBAction)didClickValueButton:(UIButton *)sender {
    if (self.didClickValueBlock) {
        self.didClickValueBlock();
    }
}
- (IBAction)didClickCoverButton:(UIButton *)sender {
    if (self.didClickCoverBlock) {
        self.didClickCoverBlock();
    }
}
@end
